﻿
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain;
using MyMES.Domain.yjb;
using MyMES.Error;
using MyMES.Writer.API.Application.Commends.settingCommand;

namespace MyMES.Writer.API.Controllers.Setting
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class settingController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<settingController> logger;

        public settingController(IMediator mediator,ILogger<settingController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 仓储设置添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<Warehouse>> Addsetting(AddCommand request)
        {
            logger.LogInformation($"在{DateTime.Now}添加了");
            return await mediator.Send(request);
        }
        /// <summary>
        /// 仓储设置删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> Delseeting(DelCommand request)
        {
            logger.LogInformation($"在{DateTime.Now}删除了");
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPut]
        public async Task<APIResult<Warehouse>> Updatesetting(UpdateCommands request)
        {
            logger.LogInformation($"在{DateTime.Now}修改了");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 工序添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<ProcessInfo>> Processinfo(ProcessInfoCommand request)
        {
            logger.LogInformation($"在{DateTime.Now}添加了");
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改工序
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<ProcessInfo>> UpdateProcessinfo(UpdateProcessInfoCommand request)
        {
            logger.LogInformation($"在{DateTime.Now}修改了");
            return await mediator.Send(request);
        }
        /// <summary>
        /// 排产添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<WorkOrderInfo>> AddWorkOrder(AddWorkOrderInfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 排产
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<TaskInfo>> AddTaskInfo(AddTaskInfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除排序
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> DelTaskInfo(DelTaskInfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPut]
        public async Task<APIResult<TaskInfo>> UpdateTaskInfo(UpdateTaskInfoCommands request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 甘特图添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<ProductionTasks>> Addgtt(AddgttCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除甘特图
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>

        [HttpPut]
        public async Task<APIResult<int>> Delgtt(DelgttCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<ProductionTasks>> Updategtt(UpdategttCommands request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 添加调拨
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<TransferOrder>> AddTB(AddTBCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        ///  删除调拨
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> DelTB(DelTBCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改调拨
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<TransferOrder>> UpdateTB(UpdateTBCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨单添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<InventoryTransfer>> AddTBS(AddInventoryTransferCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> DelTBS(DelInventoryTransferCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<InventoryTransfer>> UpdateTBS(UpdateInventoryTransferCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 采购添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<PurchaseOrder>> Addpur(AddPurchaseOrderCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
